#include<iostream>
using namespace std;
struct TreeNode
{
	int val;
	TreeNode *left;
	TreeNode *right;
	TreeNode(const int x) :val(x), left(0), right(0){}
};
//剑指offer题18：操作给定的二叉树，将其变换为源二叉树的镜像
void MirrorBinaryTree(TreeNode *root)
{
	if (!root)return;

	swap(root->left, root->right);
	MirrorBinaryTree(root->left);
	MirrorBinaryTree(root->right);
}
int main()
{
	TreeNode *head1 = new TreeNode(1);
	TreeNode *head2 = new TreeNode(2);
	TreeNode *head3 = new TreeNode(3);
	TreeNode *head4 = new TreeNode(4);
	TreeNode *head5 = new TreeNode(5);
	TreeNode *head6 = new TreeNode(6);
	TreeNode *head7 = new TreeNode(7);
	TreeNode *head8 = new TreeNode(8);
	head1->left = head2; head1->right = head3;//根
	head2->left = head4;//左子树
	head4->right = head7;
	head3->left = head5; head3->right = head6;//右子树
	head6->left = head8;
	
	MirrorBinaryTree(head1);
	cout << "hah" << endl;

	return 0;
}
